package ik.listview;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.content.DialogInterface.OnClickListener;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.AdapterView.OnItemClickListener;

public class ListviewExample extends Activity
{
 private ListView lv1;
 private String lv_arr[]={"Festival1","Festival2","Festival3","Festival4","Festival5", "Festival6","Festival7","Festival8","Festival9","Festival10","Festival11"};
 private String Festival1= "Dit is Festival 1" +
 		"Kosten zijn 5 euro" +
 		"en de minimumleeftijd is 12";
 private String Festival2= "Dit is Festival 2"+
	"Kosten zijn 6 euro" +
		"en de minimumleeftijd is 12";;
 private String Festival3= "Dit is Festival 3"+
	"Kosten zijn 7 euro" +
		"en de minimumleeftijd is 12";;
 private String Festival4= "Dit is Festival 4"+
	"Kosten zijn 0 euro" +
		"en de minimumleeftijd is 12";;
 private String Festival5= "Dit is Festival 5"+
	"Kosten zijn 12 euro" +
		"en de minimumleeftijd is 12";;
 private String Festival6= "Dit is Festival 6"+
	"Kosten zijn 8 euro" +
		"en de minimumleeftijd is 12";;
 private String Festival7= "Dit is Festival 7"+
	"Kosten zijn 13 euro" +
		"en de minimumleeftijd is 12";;
 private String Festival8= "Dit is Festival 8"+
	"Kosten zijn 16 euro" +
		"en de minimumleeftijd is 12";;
 private String Festival9= "Dit is Festival 9"+
	"Kosten zijn 19 euro" +
		"en de minimumleeftijd is 12";;
 private String Festival10= "Dit is Festival 10"+
	"Kosten zijn 11 euro" +
		"en de minimumleeftijd is 12";;
 private String Festival11= "Dit is Festival 11"+
	"Kosten zijn 3 euro" +
		"en de minimumleeftijd is 12";;
 String url1 = "http://www.google.nl/";
 String url2 = "http://www.youtube.nl/";
 String url3 = "http://www.youtube.nl/";
 String url4 = "http://www.youtube.nl/";
 String url5 = "http://www.youtube.nl/";
 String url6 = "http://www.youtube.nl/";
 String url7 = "http://www.youtube.nl/";
 String url8 = "http://www.youtube.nl/";
 String url9 = "http://www.youtube.nl/";
 String url10 = "http://www.youtube.nl/";
 String url11 = "http://www.youtube.nl/";
 @Override
 public void onCreate(Bundle icicle)
 {
 super.onCreate(icicle);
 setContentView(R.layout.main);
 lv1=(ListView)findViewById(R.id.ListView01);
 lv1.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1 , lv_arr));
 lv1.setTextFilterEnabled(true);
 lv1.setOnItemClickListener(new OnItemClickListener() {


	public void onItemClick(AdapterView<?> a, View v, int position, long id) {
 AlertDialog.Builder adb=new AlertDialog.Builder(ListviewExample.this);
 adb.setTitle(lv1.getItemAtPosition(position)+":");
	
	
 if (lv1.getItemAtPosition(position)=="Festival1"){
	 adb.setMessage(""+Festival1);
	 adb.setNegativeButton("Ok", null);
	 adb.setNeutralButton("Site", (Festival1Site()));
	 adb.setPositiveButton("Ik ga!", null);
	 } 
	 
 	
 	else if (lv1.getItemAtPosition(position)=="Festival2"){
 		adb.setMessage(""+Festival2);
 		 adb.setNegativeButton("Ok", null);
 		 adb.setNeutralButton("Site", Festival2Site());
 		 adb.setPositiveButton("Ik ga!", null);

 	}
 	else if (lv1.getItemAtPosition(position)=="Festival3"){
 		adb.setMessage(""+Festival3);
 		 adb.setNegativeButton("Ok", null);
 		 adb.setNeutralButton("Site", Festival3Site());
 		 adb.setPositiveButton("Ik ga!", null);
 	}
 	else if (lv1.getItemAtPosition(position)=="Festival4"){
 		adb.setMessage(""+Festival4);
 		 adb.setNegativeButton("Ok", null);
 		 adb.setNeutralButton("Site", Festival4Site());
 		 adb.setPositiveButton("Ik ga!", null);
 	}
 	else if (lv1.getItemAtPosition(position)=="Festival5"){
 		adb.setMessage(""+Festival5);
 		 adb.setNegativeButton("Ok", null);
 		 adb.setNeutralButton("Site", Festival5Site());
 		 adb.setPositiveButton("Ik ga!", null);
 	}
 	else if (lv1.getItemAtPosition(position)=="Festival6"){
 		adb.setMessage(""+Festival6);
 		 adb.setNegativeButton("Ok", null);
 		 adb.setNeutralButton("Site", Festival6Site());
 		 adb.setPositiveButton("Ik ga!", null);
 	}
 	else if (lv1.getItemAtPosition(position)=="Festival7"){
 		adb.setMessage(""+Festival7);
 		 adb.setNegativeButton("Ok", null);
 		 adb.setNeutralButton("Site", Festival7Site());
 		 adb.setPositiveButton("Ik ga!", null);
 	}
 	else if (lv1.getItemAtPosition(position)=="Festival8"){
 		adb.setMessage(""+Festival8);
 		 adb.setNegativeButton("Ok", null);
 		 adb.setNeutralButton("Site", Festival8Site());
 		 adb.setPositiveButton("Ik ga!", null);
 	}
 	else if (lv1.getItemAtPosition(position)=="Festival9"){
 		adb.setMessage(""+Festival9);
 		 adb.setNegativeButton("Ok", null);
 		 adb.setNeutralButton("Site", Festival9Site());
 		 adb.setPositiveButton("Ik ga!", null);
 	}
 	else if (lv1.getItemAtPosition(position)=="Festival10"){
 		adb.setMessage(""+Festival10);
 		 adb.setNegativeButton("Ok", null);
 		 adb.setNeutralButton("Site", Festival10Site());
 		 adb.setPositiveButton("Ik ga!", null);
 	}
 	 else if (lv1.getItemAtPosition(position)=="Festival11"){
 	 	adb.setMessage(""+Festival11);
 	 	 adb.setNegativeButton("Ok", null);
 	 	 adb.setNeutralButton("Site", Festival11Site());
 	 	 adb.setPositiveButton("Ik ga!", null);
 	}
 
 //adb.setMessage("Een fantastisch groot zomerfestival, met 3 grote tenten waarin verschillende bandjes spelen. Leuk voor jong en oud");


 adb.show();
 }


	private  OnClickListener Festival1Site() {
		 Intent i = new Intent(Intent.ACTION_VIEW);
		 i.setData(Uri.parse(url1));
		 startActivity(i);
		return null;}
	private OnClickListener Festival2Site() {
		 Intent i = new Intent(Intent.ACTION_VIEW);
	      i.setData(Uri.parse(url2));
		  startActivity(i);
		  return null;}		
	private  OnClickListener Festival3Site() {
		Intent i = new Intent(Intent.ACTION_VIEW);
		 i.setData(Uri.parse(url3));
		 startActivity(i);
		return null;}
	private OnClickListener Festival4Site() {
	 Intent i = new Intent(Intent.ACTION_VIEW);
	      i.setData(Uri.parse(url4));
		  startActivity(i);
		  return null;}		
	private  OnClickListener Festival5Site() {
		 Intent i = new Intent(Intent.ACTION_VIEW);
		 i.setData(Uri.parse(url5));
		 startActivity(i);
		return null;}
	private OnClickListener Festival6Site() {
		Intent i = new Intent(Intent.ACTION_VIEW);
	    i.setData(Uri.parse(url6));
	    startActivity(i);
	  return null;}		
	private  OnClickListener Festival7Site() {
		 Intent i = new Intent(Intent.ACTION_VIEW);
		 i.setData(Uri.parse(url7));
		 startActivity(i);
		return null;}
	private OnClickListener Festival8Site() {
		 Intent i = new Intent(Intent.ACTION_VIEW);
	      i.setData(Uri.parse(url8));
		  startActivity(i);
		  return null;}		
	private  OnClickListener Festival9Site() {
		 Intent i = new Intent(Intent.ACTION_VIEW);
		 i.setData(Uri.parse(url9));
		 startActivity(i);
		return null;}
	private OnClickListener Festival10Site() {
		 Intent i = new Intent(Intent.ACTION_VIEW);
	      i.setData(Uri.parse(url10));
		  startActivity(i);
		  return null;}		
	private OnClickListener Festival11Site() {
		 Intent i = new Intent(Intent.ACTION_VIEW);
	      i.setData(Uri.parse(url11));
		  startActivity(i);
return null;	
			
	}
 });
 }
}
